package xyz.xiaomuyu.moment_read_app.util;

import android.util.Log;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBUtil {
    private static final String driver = "com.mysql.jdbc.Driver";
    private static final String url ="jdbc:mysql://119.3.255.115:3306/moment_read?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
    private static final String username ="myuser";
    private static final String password = "mypassword";

    public static Connection getConn() {
        Connection connection = null;
        try {
            Class.forName(driver);
            System.out.println("driver 加载完成");
            connection = DriverManager.getConnection(url, username, password);
            Log.d("database", "getConn: connection success!!!");
        } catch (Exception e) {
            e.printStackTrace();
            Log.d("database", "getConn: connection failed!!!");
        }
        return connection;
    }
}
